-
-
Notifications
You must be signed in to change notification settings - Fork 360
Adding graham.c #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding graham.c #106
Conversation
}; | ||
|
||
int cmp_points(const void *a, const void *b) { | ||
struct point point1 = *(struct point*)a; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't copy the points, it's completely unnecessary. Just cast to struct point*
and compare them that way
} | ||
} | ||
|
||
double ccw(struct point a, struct point b, struct point c) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think ccw
is the best name here. That would make sense if it returned a bool
. I'd probably call it orientation
or something like that.
@Gustorn I changed |
}; | ||
|
||
int cmp_points(const void *a, const void *b) { | ||
if (((struct point*)a)->y > ((struct point*)b)->y) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having them as variables wasn't a bad idea, I just didn't like the copy:
struct point* pa = (struct point*) a;
struct point* pb = (struct point*) b;
if (pa->y > pb->y) {
// ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be working?
Since @Gustorn approved it, it should be fine :) |
No description provided.